/*    */ package com.zimbra.cs.dav.service.method;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.dav.DavContext;
/*    */ import com.zimbra.cs.dav.DavContext.Depth;
/*    */ import com.zimbra.cs.dav.DavContext.RequestProp;
/*    */ import com.zimbra.cs.dav.DavException;
/*    */ import com.zimbra.cs.dav.DavException.PropFindInfiniteDepthForbidden;
/*    */ import com.zimbra.cs.dav.resource.DavResource;
/*    */ import com.zimbra.cs.dav.service.DavMethod;
/*    */ import com.zimbra.cs.dav.service.DavResponse;
/*    */ import java.io.IOException;
/*    */ import org.dom4j.Document;
/*    */ import org.dom4j.Element;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class PropFind
/*    */   extends DavMethod
/*    */ {
/*    */   public static final String PROPFIND = "PROPFIND";
/*    */   
/*    */   public String getName()
/*    */   {
/* 42 */     return "PROPFIND";
/*    */   }
/*    */   
/*    */   public void checkPrecondition(DavContext ctxt) throws DavException, ServiceException
/*    */   {
/* 47 */     super.checkPrecondition(ctxt);
/* 48 */     if (ctxt.getDepth() == DavContext.Depth.infinity) {
/* 49 */       throw new DavException.PropFindInfiniteDepthForbidden();
/*    */     }
/*    */   }
/*    */   
/*    */   public void handle(DavContext ctxt)
/*    */     throws DavException, IOException, ServiceException
/*    */   {
/* 56 */     if (ctxt.hasRequestMessage()) {
/* 57 */       Document req = ctxt.getRequestMessage();
/* 58 */       Element top = req.getRootElement();
/* 59 */       if (!top.getName().equals("propfind")) {
/* 60 */         throw new DavException("msg " + top.getName() + " not allowed in PROPFIND", 400, null);
/*    */       }
/*    */     }
/*    */     
/*    */ 
/*    */ 
/* 66 */     DavContext.RequestProp reqProp = ctxt.getRequestProp();
/*    */     
/* 68 */     DavResponse resp = ctxt.getDavResponse();
/* 69 */     if (ctxt.getDepth() == DavContext.Depth.one) {
/* 70 */       resp.addResources(ctxt, ctxt.getAllRequestedResources(), reqProp);
/*    */     } else {
/* 72 */       DavResource resource = ctxt.getRequestedResource();
/* 73 */       resp.addResource(ctxt, resource, reqProp, false);
/*    */     }
/*    */     
/* 76 */     sendResponse(ctxt);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/dav/service/method/PropFind.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */